﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Data;
using System.Windows;

namespace Vision.VisionWorkshop.Common
{
	public class BoolVisibilityConverter : IValueConverter
	{
		public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
		{
			if (value is bool)
			{
				if ((bool)value)
					return Visibility.Visible;
				else
					return Visibility.Collapsed;
			}
			else if (value is Visibility)
			{
				if ((Visibility)value == Visibility.Visible)
					return true;
				else
					return false;
			}

			return value;
		}

		public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
		{
			if (value is bool)
			{
				if ((bool)value)
					return Visibility.Visible;
				else
					return Visibility.Collapsed;
			}
			else if (value is Visibility)
			{
				if ((Visibility)value == Visibility.Visible)
					return true;
				else
					return false;
			}

			return value;
		}
	}
}
